package com.campus;

import com.alibaba.fastjson.JSON;
import com.campus.app.mapper.GoodClassMapper;
import com.campus.app.mapper.StudentMapper;
import com.campus.app.mapper.UserMapper;
import com.campus.app.service.CheckClasssService;
import com.campus.app.service.impl.CheckEveningServiceImpl;
import com.campus.app.service.impl.GoodClassServiceImpl;
import com.campus.commons.entity.*;
import com.campus.commons.utils.Result;
import com.campus.commons.utils.SimpleMail;
import com.campus.commons.utils.Tool;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.Date;
import java.util.List;

@SuppressWarnings("all")
@SpringBootTest
public class yhll {
    @Autowired
    private CheckClasssService checkClasssService;
    @Test
    public void test() {
//        Result<CheckClass> checkClass = checkClasssService.getCheckHealth();
//        System.out.println(JSON.toJSONString(checkClass));
//        CheckClass checkClass = new CheckClass();
//        checkClass.setId(2);
//
//        checkClass.setIstop(2);
//        Result Up = checkClasssService.upDate(checkClass);
//        System.out.println(Up);
        Result<List<CheckClass>> checkClass = checkClasssService.getCheckClass(1, 10);
        System.out.println(JSON.toJSONString(checkClass));

    }

    @Autowired
    private CheckEveningServiceImpl checkEveningsService;
    @Test
    public void TestCheckEvening() {
        CheckEvening checkEvening = new CheckEvening();
        checkEvening.setClassid(3);
        checkEvening.setDate(new Tool().toDate("2001-1-1"));
        checkEvening.setClassroomid(2);
        checkEvening.setFactperson(1);
        checkEvening.setTeacherid(2);
        checkEvening.setLaunch("test");
    //添加
        checkEveningsService.addCheckEveningMap(checkEvening);
    //修改
        CheckEvening checkEvening1 = new CheckEvening();
        checkEvening1.setClassid(4);
        checkEvening1.setDate(new Tool().toDate("2001-1-1"));
        checkEvening1.setClassroomid(2);
        checkEvening1.setFactperson(1);
        checkEvening1.setTeacherid(2);
        checkEvening1.setLaunch("123");
        checkEveningsService.upCheckEventingMap(checkEvening1);
        //删除
        checkEveningsService.delCheckEventingMap(4);
    }


    @Autowired
    private StudentMapper studentMapper;
    @Test
    private void CheckClass() {
        List<Student> studentAll_xml = studentMapper.getStudentAll_xml(1, 10);
        System.out.println(studentAll_xml);

    }

    @Autowired
    private UserMapper userMapper;
    @Test
    public  void  add() {
        User user = new User();
        user.setOpenid("1");

        user.setQq("123123");
        user.setPhone("測試");
        user.setEmail("測試");
        user.setRoleid(-1);
        int insert = userMapper.insert(user);

        System.out.println(user.getId());
        System.out.println();
    }
    @Test
    public void tes1t() {
//Tool.sendMail("学社审核","你没有通过这次考核，不要灰心。。。","741917529@qq.com");
        SimpleMail.sendMail("随便来个主题","随便的内容","741917529@qq.com");
        SimpleMail.sendMail("随便来个主题","随便的内容","恭喜中奖了",new String[]{"首先。。。","其次。。。。XQ"},"741917529@qq.com");


    }

    @Autowired
    private GoodClassServiceImpl goodClassService;
    @Autowired
    private GoodClassMapper goodClassMapper;
    @Test
    public void mygoodTest() {
//        goodClassService.GoodClass(0, 90, "2001-01-01", "2021-02-02", 1,10);
//        QueryWrapper<GoodClass> goodClassQueryWrapper = new QueryWrapper<>();
//        goodClassQueryWrapper.groupBy("id");
//        List<GoodClass> goodClasses = goodClassMapper.selectList(goodClassQueryWrapper);
//
//        for (GoodClass goodClass : goodClasses) {
//            System.out.println(goodClass.getClassName());
//
//        }
        String s = Tool.a_month_ago(new Date());
        System.out.println(s);
    }


}

